/**
 * Copyright (c) 2004-2015 All Rights Reserved.
 */
package com.zbest.zpay.web.controller.activity;

import org.springframework.stereotype.Controller;

import com.zbest.zpay.web.controller.BaseController;

/**
 * 
 *
 * @author czhou3306@gmail.com
 * @version $Id: BonusController.java, v0.1 2015年11月26日 下午2:38:59 czhou3306@gmail.com Exp $
 */
@Controller
public class ActivityManageController extends BaseController {/*

    private static final Logger logger = LoggerFactory.getLogger(ActivityManageController.class);

    *//**
     * 查询活动列表
     * 
     * @param request
     * @param bonusDrawForm
     * @return
     *//*
    @RequestMapping(value = "/activity/query", method = RequestMethod.GET)
    @ResponseBody
    public String query(HttpServletRequest request,
                        @RequestParam(required = false) String beginDate,
                        @RequestParam(required = false) String endDate,
                        @RequestParam(required = false) String searchWord,
                        @RequestParam(required = false) String activityType,
                        @RequestParam(required = false) String pageNo,
                        @RequestParam(required = false) String pageSize) { 

        Merchant merchant = (Merchant) request.getSession().getAttribute(ContextField.KEY_MERCHANT);
        Map<String, Object> data = new HashMap<String, Object>();
        data.put(ContextField.KEY_MERCHANT_ID, merchant.getMerchantId());
        data.put(ContextField.KEY_BEGIN_DATE, beginDate);
        data.put(ContextField.KEY_END_DATE, endDate);
        data.put(ContextField.KEY_SEARCH_WORD, searchWord);
        data.put(ContextField.KEY_PAGE_NO,
            StringUtils.isBlank(pageNo) ? 1 : Integer.parseInt(pageNo));
        data.put(ContextField.KEY_PAGE_SIZE,
            StringUtils.isBlank(pageSize) ? ContextConstant.PAGE_SIZE : Integer.parseInt(pageSize));
        data.put(ContextField.KEY_ACTIVITY_TYPE, activityType);

        ProcessResult processResult = processService.execute(
            ProcessConstant.PROCESS_ACTIVITY_QUERY, data);

        if (processResult.isSuccess()) {
            return newSuccessResult(processResult.getResultObject());
        } else {
            return newErrorResult(processResult.getCode(), processResult.getCode().getMessage());
        }

    }

    *//**
     * 根据id查询活动
     * 
     * @param request
     * @param bonusDrawForm
     * @return
     *//*
    @RequestMapping(value = "/activity/queryById", method = RequestMethod.GET)
    @ResponseBody
    public String queryById(HttpServletRequest request, @RequestParam String activityId) {

        Merchant merchant = (Merchant) request.getSession().getAttribute(ContextField.KEY_MERCHANT);
        Map<String, Object> data = new HashMap<String, Object>();
        data.put(ContextField.KEY_MERCHANT, merchant);
        data.put(ContextField.KEY_ACTIVITY_ID, activityId);

        ProcessResult processResult = processService.execute(
            ProcessConstant.PROCESS_ACTIVITY_QUERY_BY_ID, data);

        if (processResult.isSuccess()) {
            return newSuccessResult(processResult.getResultObject());
        } else {
            return newErrorResult(processResult.getCode(), processResult.getCode().getMessage());
        }

    }

    *//**
     * 生成预览的二维码
     * 
     * @param request
     * @param response
     *//*
    @RequestMapping(value = "/activity/previewQrcode", method = RequestMethod.GET)
    @ResponseBody
    public String previewQrcode(HttpServletRequest request, HttpServletResponse response) {

        try {
            String activityId = request.getParameter(ContextField.KEY_ACTIVITY_ID);
            String appId = request.getParameter(ContextField.KEY_AUTHORIZER_APP_ID);

            Map<String, Object> data = new HashMap<String, Object>();
            data.put(ContextField.KEY_ACTIVITY_ID, activityId);
            data.put(ContextField.KEY_AUTHORIZER_APP_ID, appId);
            ProcessResult result = processService.execute(ProcessConstant.PROCESS_GEN_PREVIEW_URL,
                data);
            if (result.isSuccess()) {
                  response.setContentType("image/png");
                  String url = (String) result.getResultObject().get(ContextField.KEY_PREVIEW_URL);
                  ImageIO.write(QrcodeUtil.genQrcodeToBufferedImage(url), "png",
                      response.getOutputStream());

                return newSuccessResult(result.getResultObject());
            } else {
                return newErrorResult(result.getCode());
            }

        } catch (Exception e) {
            logger.error("二维码生成异常", e);
            return newErrorResult(MarketBizCodeEnum.UNKNOWN);
        }

    }

    *//**
     * 增加优惠券活动
     * 
     * @param request
     * @param loginForm
     * @return
     *//*
    @RequestMapping(value = "/activity/add", method = RequestMethod.POST)
    @ResponseBody
    public String add(HttpServletRequest request, @RequestBody ActivityForm activityForm) {

        Merchant merchant = (Merchant) request.getSession().getAttribute(ContextField.KEY_MERCHANT);
        Map<String, Object> data = new HashMap<String, Object>();
        data.put(ContextField.KEY_MERCHANT, merchant);
        data.put(ActivityForm.class.getSimpleName(), activityForm);

        ProcessResult processResult = processService.execute(ProcessConstant.PROCESS_ADD_ACTIVITY,
            data);

        if (processResult.isSuccess()) {
            return newSuccessResult(processResult.getResultObject());
        } else {
            return newErrorResult(processResult.getCode(), processResult.getCode().getMessage(),
                processResult.getResultObject());
        }

    }

    *//**
     * 更新优惠券活动
     * 
     * @param request
     * @param loginForm
     * @return
     *//*
    @RequestMapping(value = "/activity/update", method = RequestMethod.POST)
    @ResponseBody
    public String update(HttpServletRequest request, @RequestBody ActivityForm activityForm) {

        Merchant merchant = (Merchant) request.getSession().getAttribute(ContextField.KEY_MERCHANT);
        Map<String, Object> data = new HashMap<String, Object>();
        data.put(ContextField.KEY_MERCHANT, merchant);
        data.put(ActivityForm.class.getSimpleName(), activityForm);

        ProcessResult processResult = processService.execute(
            ProcessConstant.PROCESS_UPDATE_ACTIVITY, data);

        if (processResult.isSuccess()) {
            return newSuccessResult(processResult.getResultObject());
        } else {
            return newErrorResult(processResult.getCode(), processResult.getCode().getMessage(),
                processResult.getResultObject());
        }

    }


*/}
